package org.jeecg.modules.nongjt.user.controller;


import com.alibaba.druid.util.StringUtils;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.jeecg.common.api.vo.Result;

import org.jeecg.modules.nongjt.user.entity.NjtUserRegister;
import org.jeecg.modules.nongjt.user.service.INjtUserRegisterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 用户注册信息 前端控制器
 * </p>
 *
 * @author tianshao
 * @since 2022-06-14
 */
@RestController
@RequestMapping("/njt-user-register")
public class NjtUserRegisterController {
    @Autowired
    private INjtUserRegisterService iNjtUserRegisterService;
    @GetMapping("/page")
    public Result<?> selectByPage(@RequestParam(defaultValue = "1")int current,
                                  @RequestParam(defaultValue = "3")int pageSize,
                                  NjtUserRegister njtUserRegister){
        System.out.println(njtUserRegister);
        QueryWrapper<NjtUserRegister> njtUserRegisterQueryWrapper = new QueryWrapper<>();
        Page<NjtUserRegister> page = new Page<>(current, pageSize);
        if (njtUserRegister!=null)
        {
            if (!StringUtils.isEmpty(njtUserRegister.getCompanyName()))
            {
                njtUserRegisterQueryWrapper.like("company_name",njtUserRegister.getCompanyName());
            }

        }
        if (njtUserRegister!=null)
        {
            if (!StringUtils.isEmpty(njtUserRegister.getMobilePhone()))
            {
                njtUserRegisterQueryWrapper.eq("mobile_phone",njtUserRegister.getMobilePhone());
            }

        }
        iNjtUserRegisterService.page(page, njtUserRegisterQueryWrapper);
        return Result.OK(page);
    }
}

